function check() {
	var c = $("#mobile").val();
	if(c==null || c.length<11){
		layer.msg("请输入正确的手机号");
		return ;
	}
	$.ajax({
		url: "check",
		data: {
			'mobile': c
		},
		type: "get",
		success: function(a) {
			var b = JSON.parse(a);
			if(b.msg=="ok"){
				var c= JSON.parse(b.result);
				if(c.data.amount==15 && c.data.sum_condition==15){
					layer.msg($("#mobile").val()+"未注册,已为您领取了"+c.data.sum_condition+"减"+c.data.amount+"的红包")
				}else{
					layer.msg($("#mobile").val()+"已注册,已为您领取了"+c.data.sum_condition+"减"+c.data.amount+"的红包")
				}
			}else{
				layer.msg(b.msg)
			}
		}
	})
}
function sendCode() {
	var c = $("#loginMobile").val();
	var e = $("#captchaValue").val();
	if(c==null || c.length<11){
		layer.msg("请输入正确的手机号");
		return ;
	}
	$.ajax({
		url: "sendCode",
		data: {
			'mobile': c,
			'captchaValue':e
		},
		type: "post",
		success: function(a) {
			console.log(a);
			if(a=="success"){
				layer.msg("短信验证码发送成功")
			}else{
				layer.msg(a);
				$("#PicDiv").css("display","block")
				if(a=='账户存在风险,需要图形验证码' || a=='图形验证码错误'){
					$.ajax({
						url: "captchas",
						data: {
							'mobile': c
						},
						type: "post",
						success: function(a) {
							console.log(a);
							$("#captchaValuePic").attr("src",a);
							}
						});
				}
				
			}
		}
	})
}
function login() {
	var c = $("#loginMobile").val();
	var e = $("#validateCode").val();
	if(c==null || c.length<11 || e.length<4){
		layer.msg("请输入正确的手机号或验证码");
		return ;
	}
	$.ajax({
		url: "login",
		data: {
			'mobile': c,
			'validateCode':e
		},
		type: "post",
		success: function(a) {
			console.log(a)
			var b = JSON.parse(a);
			if(typeof(b.user_id)!='undefined' && b.user_id!=""){
				layer.msg("登陆成功")
			}else{
				layer.msg("登陆失败")
			}
		}
	})
}
function assistanceVote() {
	$.ajax({
		url: "ballots",
		type: "get",
		success: function(a) {
			var a = JSON.parse(a);
			var id=a.data[0].id
			$.ajax({
				url: "assistanceVote?id="+id,
				type: "get",
				success: function(a) {
					console.log(a);
					var a = JSON.parse(a);
					if(a.code=='200'){
						layer.msg(a.data[0].title+":"+a.data[0].amount+',元'+a.data[0].description);
					}else{
						layer.msg(a.message)
					}
				}
			})
		}
	})
}
function supervip() {
	$.ajax({
		url: "supervip",
		type: "get",
		success: function(a) {
			console.log(a)
			layer.msg(a);
		}
	})
}
function hongbao() {
	$.ajax({
		url: "hongbao",
		type: "get",
		success: function(a) {
			var b = JSON.parse(a);
			if(typeof(b.message)!='undefined'){
				layer.msg(b.message);
				return ;
			}
			var str='';
			for (var i = 0; i < b.length; i++) {
				str=str + b[i].sum_condition+"-"+b[i].amount+"的"+b[i].name+"|"	
			}
			console.log(str);
			if(str!=''){
				str=str.substring(0,str.length-1);
				layer.msg("共"+b.length+"个红包，分别为"+str)
			}else{
				layer.msg("共"+b.length+"个红包，分别为"+str)
			}
			
		}
	})
}
function invite() {
	$.ajax({
		url: "invite",
		type: "post",
		success: function(a) {
			console.log(a)
		}
	})
}